/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 * \file
 * \brief Access Point Service Base entry point header
 * \author Antti Maula <antti.maula@tkk.fi>
 */
#ifndef _GIMNETAP_COMMON_APSERVICEBASE_H_
#define _GIMNETAP_COMMON_APSERVICEBASE_H_

#include <inttypes.h>
#include "protocol/fastProtocolHdr.h"
#include "protocol/hubctrlHdr.h"
#include "protocolDispatcher.h"



typedef void (*fastProtocolHandlerFuncPtr)   (const TFastProtocolHeader *framehdr,
                                              const unsigned char *payload,
                                              const unsigned int payloadSize,
                                              void *userPtr);
typedef void (*hubctrlProtocolHandlerFuncPtr) (const THubCtrlProtocolHeader *framehdr,
                                               void *userPtr);
typedef int (*serviceInitHandlerFuncPtr)     (TProtocolDisp *link);
typedef void (*serviceDeinitHandlerFuncPtr)  (TProtocolDisp *link);
typedef void (*getQueryStatsFuncPtr)         (long unsigned int *successfull_query_count,
                                              long unsigned int *failed_query_count);



void apservicebaseSetServiceInfo(const char const *name, 
                                 const uint32_t nodeid,
                                 const uint32_t typeid);
void apservicebaseSetHubCtrlKey(const uint8_t const *key, const unsigned int size);
void apservicebaseSetDefaultOperationTimeout(const unsigned int timeout_ms);
void apservicebaseRegisterFastProtocolHandler(fastProtocolHandlerFuncPtr fptr);
void apservicebaseRegisterHubCtrlProtocolHandler(hubctrlProtocolHandlerFuncPtr fptr);

void apservicebaseRegisterServiceInitHandler(serviceInitHandlerFuncPtr fptr);
void apservicebaseRegisterServiceDeinitHandler(serviceDeinitHandlerFuncPtr fptr);
void apservicebaseRegisterGetQueryStats(getQueryStatsFuncPtr fptr);

void apservicebaseInitSignalHandler(void);

int apservicebaseExecuteService(TProtocolDisp *link);

uint32_t apservicebaseGetLocalNodeId(void);

#endif
